import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    id: 0,
    name: '',
    nameZw: '',
    publisherStyle: '',
    // zhiwei:'',  // 保留被注释的原始字段
    roleId: '',
    roleName: '',
    jsqx: '',       // 结算权限
    socket: '',
    publisherType: '',  // 出版社类型 hq / tjjt
    relationUserList: [],  // 关联用户列表
    
    // 以下为mutations中使用但state未声明的字段
    bianshiid: null,
    bianshiname: null,
    publisherid: null,
    branchid: null,
    superAdmin: null,
    isadmin: null
  }),
  actions: {
    // 原mutations方法完整转换
    updateId(id) {
      this.id = id
    },
    updateName(name) {
      this.name = name
    },
    /* 保留被注释的原始方法
    updateZhiwei(zhiwei) {
      this.zhiwei = zhiwei
    },*/
    updateNameZw(nameZw) {
      this.nameZw = nameZw
    },
    SET_SOCKET(socket) {
      this.socket = socket
    },
    bianshiid(bianshiid) {
      this.bianshiid = bianshiid
    },
    bianshiname(bianshiname) {
      this.bianshiname = bianshiname
    },
    roleId(roleId) {
      this.roleId = roleId
    },
    roleName(roleName) {
      this.roleName = roleName
    },
    publisherid(publisherid) {
      this.publisherid = publisherid
    },
    branchid(branchid) {
      this.branchid = branchid
    },
    updatePublisherStyle(publisherStyle) {
      this.publisherStyle = publisherStyle
    },
    superAdmin(superAdmin) {
      this.superAdmin = superAdmin
    },
    isadmin(isadmin) {
      this.isadmin = isadmin
    },
    updateJsqx(jsqx) {
      this.jsqx = jsqx
    },
    updatePublisherType(type) {
      this.publisherType = type
    },
    setRelationUserList(list) {
      this.relationUserList = list
    }
  }
})